package com.qf.util;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryOneTime;

/**
 * 连接ZK
 * @author
 */
public class ZkClient {


    public static CuratorFramework getClient() {
        // 重试策略
        RetryPolicy retryPolicy = new RetryOneTime(2000);
        // 构建连接对象
        CuratorFramework cf = CuratorFrameworkFactory.builder()
                .connectString("192.168.41.98:2181,192.168.41.98:2182,192.168.41.98:2183")
                .retryPolicy(retryPolicy)
                .build();
        // 开启连接
        cf.start();
        return cf;
    }

}
